//
//  CustomNavigationController.m
//  Cszy
//
//  Created by SC on 16/6/29.
//  Copyright © 2016年 SC. All rights reserved.
//

#import "BasicNavigationController.h"

@interface BasicNavigationController ()

@property (nonatomic, assign) BOOL isUpdate;

@end

@implementation BasicNavigationController

+ (void)reload
{
    //[BasicNavigationController sharedInstance].isUpdate = YES; 有问题啊？？
}

+ (instancetype)sharedInstance
{
    static BasicNavigationController *navController = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        navController = [[BasicNavigationController alloc] init];
        
    });
    return navController;
}



- (BOOL)shouldAutorotate{
    
    if ([BasicNavigationController sharedInstance].isUpdate) {
        [BasicNavigationController sharedInstance].isUpdate = NO;
        return YES;
    }
    

    return self.topViewController.shouldAutorotate;
}



- (void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
}

- (void)viewDidLoad{
    
    [super viewDidLoad];
    
    [self initConfig];
}

- (void)initConfig{

    self.themeColor = HEXCOLOR(kColorBlue1, 1);
    self.tintColor = [UIColor whiteColor];
}

- (UIViewController *)childViewControllerForStatusBarStyle{
    
    return self.topViewController;
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if (self.viewControllers.count > 0) { // 如果现在push的不是栈底控制器(最先push进来的那个控制器)
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
    
    // 修改tabBra的frame
    CGRect frame = self.tabBarController.tabBar.frame;
    frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
    self.tabBarController.tabBar.frame = frame;
    
}



@end
